﻿
@{
    Layout = null;
}

<style>
    .ngdialog.ngdialog-theme-plain .ngdialog-content {
        width: 25% !important;
    }
</style>
<div ng-controller="CounponListController">
    <h3>优惠券明细</h3>

    <div class="panel panel-default" ng-class="{ 'whirl standard': isLoading}">
        <div class="panel-heading">
            <div class="form-inline ng-pristine ng-valid">
                <div class="form-group">
                    <button type="submit" class="btn btn-labeled btn-success" ng-click="$state.go('app.couponlist')">
                        <span class="btn-label">
                            <em class="fa fa-reply"></em>
                        </span>返回
                    </button>
                </div>
            </div>
        </div>
        <div class="panel-body">
            <div class="table-responsive">
                <table ng-table="tableParams" class="table table-striped table-bproducted table-hover">
                    <tbody>
                        <tr ng-repeat="item in $data">
                            <td data-title="'优惠券名称'" class="text-center">{{item.CouponName}}</td>
                            <td data-title="'来源'" class="text-center">{{item.SourceTypeDes}}</td>
                            <td data-title="'会员昵称'" class="text-center">{{item.MemberName}}</td>
                            <td data-title="'使用时间'" class="text-center">{{item.UsedTime}}</td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script>
    App.controller('CounponListController', [
    '$scope', '$resource', '$state', '$route', '$http', 'ngTableParams', 'ngTableDataService', 'Notify', '$filter', 'ngDialog', "$stateParams", "$timeout", "toaster",
        function ($scope, $resource, $state, $route, $http, ngTableParams, ngTableDataService, Notify, $filter, ngDialog, $stateParams, $timeout, toaster) {
            'use strict';
            $scope.isLoading = true;
            //数据查询
            $scope.tableParams = new ngTableParams({
                page: 1,
                count: 10,
                sorting: {
                    Id: 'desc'     // 初始化排序
                }
            }, {
                getData: function ($defer, params) {
                    $scope.isLoading = true;
                    var requestParams = {
                        Skip: (params.page() - 1) * params.count(),
                        Take: params.count(),
                        CouponId: $stateParams.id
                    };
                    $http.post('/Coupon/GetCounponDetailList', ngTableDataService.getServerSideParams(params.orderBy().toString(), params, requestParams))
                        .success(function (data, status) {
                            params.total(data.count);
                            $defer.resolve(data.data);
                            $scope.isLoading = false;
                        });
                }
            });




        }
    ]);
</script>
